package com.cn.hotel.servlet.front;

import com.alibaba.fastjson.JSONObject;
import com.cn.hotel.model.CompanyInformationModel;
import com.cn.hotel.model.FacilitiesModel;
import com.cn.hotel.model.NavModel;
import com.cn.hotel.model.ServiceItemsModel;
import com.cn.hotel.service.ICompanyInformationService;
import com.cn.hotel.service.IFacilitiesService;
import com.cn.hotel.service.INavService;
import com.cn.hotel.service.IServiceItemsService;
import com.cn.hotel.service.impl.CompanyInformationServiceImpl;
import com.cn.hotel.service.impl.FacilitiesServiceImpl;
import com.cn.hotel.service.impl.NavServiceImpl;
import com.cn.hotel.service.impl.ServiceItemsServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/getFacilitiesModelList")
public class FacilitiesServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //获取设施介绍列表
        req.setCharacterEncoding("utf-8");
        resp.setCharacterEncoding("utf-8");
        String page = req.getParameter("page");
        Integer pageNumber = page==null||"".equals(page)?1:Integer.parseInt(page);
        IFacilitiesService iFacilitiesService = new FacilitiesServiceImpl();
        List<FacilitiesModel> list = iFacilitiesService.getFacilitiesModel(pageNumber);
        int number = iFacilitiesService.getCount();
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("list",list);
        jsonObject.put("number",number);
        resp.getWriter().println(jsonObject);
    }
}
